package demo2;


public class Work2 {
    public static void main(String[] args) {
        MyThread thread1=new MyThread();
        Thread thread2=new Thread(new MyRunnable());
        Thread thread3=new Thread(){
            @Override
            public void run() {
                System.out.println("自定义类使用匿名内部类的方式正在运行");
            }
        };
        Thread thread4=new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("自定义线程类使用匿名内部类正在运行");
            }
        });
        Thread thread5=new Thread(()->{
            System.out.println("使用Lambda创建线程");
        });
        thread1.start();

        thread2.start();
        thread3.start();
        thread4.start();
        thread5.start();
    }

}
class MyThread extends Thread{
    @Override
    public void run() {
            System.out.println("MyThread正在运行");

    }
}
class MyRunnable implements  Runnable{
    @Override
    public void run() {
            System.out.println("自定义线程任务正在执行");

    }
}
